package com.nvwa.mvp.easyexcel.service;

import com.nvwa.dto.query.PageQuery;
import com.nvwa.easyexcel.EasyExcelHelper;
import com.nvwa.mvp.easyexcel.mapper.UserMapper;
import com.nvwa.mvp.easyexcel.po.User;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Service
public class UserService {
    @Autowired
    UserMapper userMapper;

    @SneakyThrows
    public void excel(PageQuery query, HttpServletResponse response) {
        List<User> list = userMapper.selectList();
        EasyExcelHelper.export(list, User.class, "user", response, "id");
    }
}